var express = require('express');
var proCtrl = require('./controllers/product');
var clzCtrl = require('./controllers/classify');
var addressCtrl = require('./controllers/address');
var collectCtrl = require('./controllers/collect');
var couponCtrl = require('./controllers/coupon');
var centerCtrl = require('./controllers/conCenter');
var userCtrl = require('./controllers/conUser');
var cartCtrl=require('./controllers/cart.js');
var orderCtrl = require('./controllers/order');
var homeCtrl = require('./controllers/home');
var signDayCtrl = require('./controllers/signday.js');
var groupCtrl = require('./controllers/group.js');

var initCtrl = require('./controllers/commonAPI.js');
var router = express.Router();
//初始化：读取会员等级和活动

router.get('/init',initCtrl.initialize);
//创建了product的路由
router.get('/p/:id', proCtrl.getById);
//根据商品的分类的简码来列举商品列表，分页
router.get('/p/l/:cname/:p', proCtrl.listByClass);
router.get('/classify',clzCtrl.index);
router.post('/classify/search/:name',clzCtrl.search);
router.get('/classify/prolist/:classifyId',clzCtrl.listByClassifyId)
//个人中心
//router.get('/user/center',centerCtrl.center);
router.get('/user/center/history',centerCtrl.history);
router.get('/user/center/groupHistory',centerCtrl.groupHistory);
router.get('/user/center/member',centerCtrl.member);
router.get('/user/center/coupon',centerCtrl.coupon);
router.get('/user/center/address',addressCtrl.listAddressUi);
router.get('/user/center/collect',centerCtrl.collect);
//我的地址scor
router.get('/user/center/getAddress',addressCtrl.listAddress);//
router.get('/user/center/setDefaultAddress',addressCtrl.setDefaultAddress);
router.get('/user/center/getDefaultAddress',addressCtrl.getDefaultAddress);
router.get('/user/center/deleteAddress',addressCtrl.deleteAddress);
router.post('/user/center/saveAddress',addressCtrl.saveAddress);
//我的优惠券scor
router.post('/user/center/getUserCouponsList',couponCtrl.getUserCouponsList);
router.post('/user/center/getCouponCode',couponCtrl.getCouponCode);
//我的收藏scor
router.post('/user/center/getUserCollect',collectCtrl.getUserCollect);
router.get('/user/center/removeUserCollect',collectCtrl.removeUserCollect);

//购物车相关路由规则
router.get('/cart',cartCtrl.index);
router.get('/cart/getGoodsPriceAjax',cartCtrl.getGoodsPriceAjax);
router.get('/cart/getActivityRuleMJAjax',cartCtrl.getActivityRuleMJAjax);
router.get('/cart/getActivityRuleMSAjax',cartCtrl.getActivityRuleMSAjax);
router.get('/cart/setProductCheckedAjax',cartCtrl.setProductCheckedAjax);
router.get('/cart/delCartProductAjax',cartCtrl.delCartProductAjax);
router.get('/cart/setProductQuantityAjax',cartCtrl.setProductQuantityAjax);
router.get('/cart/getProductListAjax',cartCtrl.getProductListAjax);
router.get('/cart/setProductCheckedAllAjax',cartCtrl.setProductCheckedAllAjax);
router.get('/cart/setProductCheckAjax',cartCtrl.setProductCheckAjax);
router.get('/cart/singlebuy',cartCtrl.singlebuy);
router.get('/cart/getProductListAjax',cartCtrl.getProductListAjax);
router.get('/cart/getProList',cartCtrl.getProList);

/*@ end to scor*/

//根据商品的分类的简码来列举商品列表，分页
router.get('/p/l/:cname/:p', proCtrl.listByClass);
router.get('/classify',clzCtrl.index);
router.get('/classify/search/:name',clzCtrl.search);
router.get('/classify/searchForm/',clzCtrl.searchForm);
router.get('/classify/searchRm/:name',clzCtrl.searchRm);
router.get('/classify/searchJg/:name',clzCtrl.searchJg);
router.get('/classify/proListById/:classifyId',clzCtrl.listByClassifyId);
router.get('/classify/proListByIdRm/:classifyId',clzCtrl.listByClassifyIdRm);
router.get('/classify/proListByIdJg/:classifyId',clzCtrl.listByClassifyIdJg);
router.get('/classify/proListByCode/:classifyCode',clzCtrl.listByClassifyCode);
router.get('/classify/products',clzCtrl.getAllProduct);
router.get('/classify/productsRm',clzCtrl.getAllProductRm);
router.get('/classify/productsJg',clzCtrl.getAllProductJg);
//签到活动
router.get('/activity/signday',signDayCtrl.index);
router.get('/activity/getSignDayValueAjax',signDayCtrl.getSignDayValueAjax);
router.get('/activity/getSignDayDetailAjax',signDayCtrl.getSignDayDetailAjax);
router.get('/activity/setSignDayActionAjax',signDayCtrl.setSignDayActionAjax);
router.get('/activity/setSignDayGiftGiveAjax',signDayCtrl.setSignDayGiftGiveAjax);


router.get('/classify/getClassifyProductListAjax',clzCtrl.getClassifyProductListAjax);
router.get('/classify/productsLimit',clzCtrl.getClassifyProductLimit);

//商品详情页
router.get('/detail/:id',proCtrl.getDetailById);
//加入收藏
router.get('/product/selected',proCtrl.addUserCollect);
//加入购物车
router.get('/product/addToCart',proCtrl.addToCart);
//立即结算
router.get('/product/accountNow',proCtrl.accountNow);
//获取评论列表
router.get('/product/getAllComment',proCtrl.getAllComment);
router.get('/product/mmm',proCtrl.common);

//订单
router.get('/order/confirmOrder/:aid',orderCtrl.confirmOrder);
router.get('/order/confirmOrderUI',orderCtrl.confirmOrderUI);
router.get('/order/addOrder',orderCtrl.addOrder);
router.get('/order/getOrderListByAll',orderCtrl.getOrderListByAll);
router.get('/order/getOrderListByPay',orderCtrl.getOrderListByPay);
router.get('/order/getOrderListByReceived',orderCtrl.getOrderListByReceived);
router.get('/order/getOrderListByEvaluation',orderCtrl.getOrderListByEvaluation);
router.get('/order/getOrderListByComplete',orderCtrl.getOrderListByComplete);
router.get('/order/notify',orderCtrl.notify);
router.get('/order/setOrderCancel/:objectId',orderCtrl.setOrderCancel);
router.get('/order/againPay',orderCtrl.againPay);

router.get('/user/center/getAddress',addressCtrl.listAddress);
router.get('/group',groupCtrl.group);

router.get('/order/pay',function(req,res){
 res.render('wx/order',{title:'pay'});
});

//首页
router.get('/home',homeCtrl.getHomepage);


//jun star
router.get('/user/center',centerCtrl.getPointsAmountByOpenID);
router.get('/user/member',userCtrl.getUserInfo);
router.get('/user/history/:orderType',userCtrl.getOrdersByType);
router.get('/user/nghistory/:orderType',userCtrl.getOrdersByTypeNG);
router.get('/user/minusAmount',userCtrl.minusAmount);
router.get('/user/updatePoints',userCtrl.updatePoints);
router.get('/user/getPoints',userCtrl.getPoints);
router.get('/user/chongzhi',userCtrl.chongZhiUrl);
router.get('/user/recharge/:orderid/:amount',userCtrl.chongZhiOrder);
//router.get('/user/ifbindphone',userCtrl.ifBindPhone);
//router.get('/user/bindphone/:phone',userCtrl.bindPhone);
router.get('/user/eva/:orderid',userCtrl.pinjia);
router.get('/user/saveeva/:orderid/:content/:pid/:pname/:score',userCtrl.savePinJia);
router.get('/user/shouhuo/:orderid',userCtrl.shouhuo);
router.get('/user/bindPhone',userCtrl.judgeBindPhone);
router.get('/user/password/:pwdtype',userCtrl.handlePWD);
router.get('/user/smsphone/:phone',userCtrl.sendsmscode);
router.get('/user/smscode',userCtrl.j);
router.get('/user/ghbdphone',userCtrl.ghphone);
router.get('/user/saveyepwd',userCtrl.saveyepwd);
router.get('/user/ifsetpwd',userCtrl.ifSetpwd);
router.get('/user/xgpassword',userCtrl.reSetpwd);
router.get('/user/findpwd',userCtrl.findpwd);
router.get('/user/savewjpwd',userCtrl.savewjpwd);
//jun end

router.get('/',homeCtrl.getHomepage);

module.exports = router;